// 渲染进程prod环境webpack配置
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const {merge} = require('webpack-merge');

const webpackBaseConfig = require('./webpack.common');

const htmlWebpackPlugin = new HtmlWebpackPlugin({
  inject: 'body',
  scriptLoading: 'defer',
  template: path.join(__dirname, '../public/index.html'),
  minify: false,
  filename: `index.html`,
});

module.exports = merge(webpackBaseConfig, {
  devtool: 'none',
  mode: 'production',
  target: 'electron-renderer',
  entry: {
    renderer: require.resolve('../src/renderer/index.js'),
  },
  output: {
    path: path.join(__dirname, '..', '../dist'),
    publicPath: './dist/',
    filename: '[name].prod.js',
  },
  plugins:[
    new webpack.EnvironmentPlugin({
      NODE_ENV: 'production',
    }),
    htmlWebpackPlugin
  ]
});
